//
//  UserViewController.m
//  OpenYourEyes
//
//  Created by 沈振烨 on 15/8/19.
//  Copyright (c) 2015年 zhanglei. All rights reserved.
//

#import "UserViewController.h"
#import "Header.h"

@interface UserViewController ()

@property (nonatomic ,strong) UIScrollView *scrollView;

@property (nonatomic ,strong) UILabel *labelTitle;

@property (nonatomic ,strong) UILabel *labelFristTitle;

@property (nonatomic ,strong) UILabel *labelSecondTitle;

@property (nonatomic ,strong) UILabel *labelFrist;

@property (nonatomic ,strong) UILabel *labelSecond;

@property (nonatomic ,strong) UILabel *labelThree;

@end

@implementation UserViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationItem.title = @"用户协议";
    self.view.backgroundColor = [UIColor whiteColor];
    [self userNegotiate];
}

- (void)userNegotiate
{
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    _scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT + 50);

    [self.view addSubview:_scrollView];
    
    _labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 30)];
    _labelTitle.text = @"软件用户协议";
    _labelTitle.font = [UIFont fontWithName:@"Arial-BoldMT" size:20];
    _labelTitle.textAlignment = NSTextAlignmentCenter;
    
    _labelFristTitle = [[UILabel alloc] initWithFrame:CGRectMake(_labelTitle.left + 30, _labelTitle.bottom + 20, _labelTitle.width, _labelTitle.height)];
    _labelFristTitle.text = @"一、用户协议接受";
    _labelFristTitle.font = [UIFont fontWithName:@"ArialHebrew" size:17];
    
    [_scrollView addSubview:_labelFristTitle];
    [_scrollView addSubview:_labelTitle];
    
    _labelFrist = [[UILabel alloc] initWithFrame:CGRectMake(_labelFristTitle.left, _labelFristTitle.bottom + 15, _labelFristTitle.width - 60, 30)];
    _labelFrist.text = @"1、本用户协议(简称“协议”)是由个人团队所定义的相关义务规范，用于使用本软件服务来提供的详细规定，因此，本视频不能用于商业范畴，切实详细地阅读本协议的相关内容。";
    _labelFrist.font = [UIFont systemFontOfSize:14];
    _labelFrist.numberOfLines = 0;
    _labelFrist.textColor = [UIColor grayColor];
    _labelFrist.alpha = 0.9;
    
    [_scrollView addSubview:_labelFrist];
    
    _labelFrist.frame = CGRectMake(_labelFristTitle.left, _labelFristTitle.bottom + 15, _labelFristTitle.width - 60, [self heightWithString:_labelFrist]);
    
    
    
    _labelSecond = [[UILabel alloc] initWithFrame:CGRectMake(_labelFristTitle.left, _labelFrist.bottom + 15, _labelFristTitle.width - 60, 30)];
    _labelSecond.text = @"2、只要使用本软件务使用到商业范畴，以及无条件接收了本协议的相关规定，并愿意受其约束，如果发生纠纷，应当自行承担事实上未认真阅读本条款的责任，不得以未仔细阅读为由进行抗辩。";
    _labelSecond.font = [UIFont systemFontOfSize:14];
    _labelSecond.numberOfLines = 0;
    _labelSecond.textColor = [UIColor grayColor];
    _labelSecond.alpha = 0.9;
    
    [_scrollView addSubview:_labelSecond];
    
    _labelSecond.frame = CGRectMake(_labelFrist.left, _labelFrist.bottom + 15, _labelFristTitle.width - 60, [self heightWithString:_labelSecond]);
    
    
    _labelSecondTitle = [[UILabel alloc] initWithFrame:CGRectMake(_labelTitle.left + 30, _labelSecond.bottom + 20, _labelTitle.width, _labelTitle.height)];
    _labelSecondTitle.text = @"二、使用规则";
    _labelSecondTitle.font = [UIFont fontWithName:@"ArialHebrew" size:17];
    
    [_scrollView addSubview:_labelSecondTitle];
    
    
    
    _labelThree = [[UILabel alloc] initWithFrame:CGRectMake(_labelFristTitle.left, _labelSecondTitle.bottom + 15, _labelFristTitle.width - 60, 30)];
    _labelThree.text = @"1、在使用该APP的时候，并保证遵守以下原则：\
                          \
                          (1) 遵守中国有关的法律和法规;\
                          \
                          (2) 遵守本条款发布的相关管理规定;\
                          \
                          (3) 不得以任何形式侵犯本软件的合法利益;\
                          \
                          \
                          (4) 未经同意不能用于商业范畴;";
    _labelThree.font = [UIFont systemFontOfSize:14];
    _labelThree.numberOfLines = 0;
    _labelThree.textColor = [UIColor grayColor];
    _labelThree.alpha = 0.9;
    
    [_scrollView addSubview:_labelThree];
    
    _labelThree.frame = CGRectMake(_labelFrist.left, _labelSecondTitle.bottom + 15, _labelFristTitle.width - 60, [self heightWithString:_labelThree]);
    
}
- (CGFloat)heightWithString:(UILabel *)label
{
    
    CGSize size = [label.text boundingRectWithSize:CGSizeMake(label.frame.size.width, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]} context:nil].size;
    return size.height;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
@end
